/*
 * TownObjects.hpp
 *
 *  Created on: Sep 6, 2013
 *      Author: jason
 */

#ifndef TOWNOBJECTS_HPP_
#define TOWNOBJECTS_HPP_
#include <vector>
#include <unordered_map>
#include "TownMode.hpp"
#include "../ObjectManager.hpp"

namespace OForce_Mode {
class ObjectManager {
friend class TownMode;
public:
	ObjectManager();
	~ObjectManager();
	int getNumObjects() {return vObjects.size();}
	Object *getObject(int id);
	int getNumCharacters() {return vCharacters.size();}
	// Sorts objects by layer for efficient drawing
	void sortObjects();
	void update();
	void drawLayer(int layer);
	Object *findInteractable(Character *character, float searchDistance = 16.0f);
	bool collisionCheck(Object* obj);
	// If an object collides with another, check to see if it is possible to
	// do a slight adjustment and do that.
	// This allows the character move more naturally around obstacles.
	bool adjustPathAroundCollision(Character *character, Object* obj);
	// Do A-Star path-finding
	bool findPath(Character *character, std::vector<PathNode> &path, PathNode dest);
private:
	std::unordered_map<int, Object *> objectMap;
	std::vector<Character *> vCharacters;
};

} // namespace OForce_Mode

#endif /* TOWNOBJECTS_HPP_ */
